  require 'mechanize'

  logfile = File.new('log.txt','w')
  login='##'
  password = '##'
  agent = WWW::Mechanize.new
  page = agent.get('http://di.se/login/login_trader.aspx?P=4&DoLogin=Y')
  #link = page.links.text(/Log In/)
  #page = agent.click(link)
  form = page.forms.with.name("LoginForm").first
  form.fields.each { |f| puts f.name }
  form.DITName = login
  form.DITPSW = password
  page = agent.submit(form,form.buttons.first)
  page = agent.get("http://portfolio.di.se/showportfolio.aspx?portfolioId=200527")
puts '------------------------------------------------------------------------'
  puts page.body
  logfile.print(page.body)
puts '------------------------------------------------------------------------'
  page.header.each {|key, value| puts key + "  " + value}
  logfile.close